<link rel="stylesheet" type="text/css" href="../public/js/artEdit/css/style.css">
<script type="text/javascript" src="../public/js/artEdit/js/index.min.js"></script>
<style type="text/css">
    .icon-image:before{ position: absolute; right: 0; top: 8px; }
</style>
<div class="aui-list-item" >
    <div class="aui-list-item-inner">
        <input type="hidden" name="{$file_name}" id="{$file_name}">
        <div class="aui-list-item-input border-1" id="{$file_name}-artedit" href="{:url('File/wap_edit_upload')}" style="padding-right: 10px;padding-left: 10px;min-height: 150px;">

        </div>
    </div>
</div>
<!-- <div class="aui-list-item">
    <div class="aui-list-item-inner">
        <div class="upload-img">
        	<div class="icon-image"></div>
        	<input class="input-file" id="imageUpload" type="file" name="fileInput" capture="camera" accept="image/*" style="">
        </div>
    </div>
</div> -->
<script type="text/javascript">
	$(function () {
    "use strict";
    var service = $('#{$file_name}-artedit').attr('href');
    $('#{$file_name}-artedit').artEditor({
        imgTar: '#imageUpload',
        limitSize: 5,   // 兆
        showServer: true,
        uploadUrl: service,
        data: {},
        uploadField: 'image',
        placeholader: '<p>{$field_dec}</p>',
        validHtml: ["<br/>"],
        formInputId: '{$file_name}',
        uploadSuccess: function (res) {
            // 这里是处理返回数据业务逻辑的地方
            // `res`为服务器返回`status==200`的`response`
            // 如果这里`return <path>`将会以`<img src='path'>`的形式插入到页面
            // 如果发现`res`不符合业务逻辑
            // 比如后台告诉你这张图片不对劲
            // 麻烦返回 `false`
            // 当然如果`showServer==false`
            // 无所谓咯
            var result = JSON.parse(res)
            if (result['code'] == '100') {
                return result['data']['url'];
            } else {
                switch (result['code']) {
                    case '101': {
                        alert('图片太大之类的')
                    }
                }
            }
            return false;
        },
        uploadError: function (status, error) {
            //这里做上传失败的操作
            //也就是http返回码非200的时候
            alert('网络异常' + status)
        }
    });
});
</script>